<?php
    if(empty($_SESSION['home'])){
        redirect("请先登录",3,ROOT_URL . "login.php");
        die;
    }
    //获取登录用户的id

    $id = $_SESSION['home']['id'];
    //如果$_GET['act']没有,就赋值它为user_info查个人信息
    if(empty($_GET['act'])){
        $_GET['act'] = 'user_info';
    }
    if(!empty($_GET['act'])){
        $act = $_GET['act'];
        switch($act){
            //我的订单
            case 'myorder':
                //查询我的订单
                $sql = "select * from ".PRE."order where user_id='$id' order by create_time desc";
                $order_list = query($link, $sql);
            break;
            //已买到的宝贝
            case 'bought':
                //查询我的订单,已经付过款
                $sql = "select * from ".PRE."order where user_id='$id' and pay_status=1 and shipping_status=1 order by create_time desc";
                $order_list = query($link, $sql);
                break;
            //个人信息
            case 'user_info' :
                $sql = "select * from ".PRE."user where id='$id'";
                $user_info = getRow($link,$sql);
                break;
            case 'user_head' :
                $sql = "select * from ".PRE."user where id='$id'";
                $user_info = getRow($link,$sql);
                break;
        }
    }

?>

<div class="container mt50">
    <div class="row mt50 col-md-3">
        <div>
            <ul>
                <li class="btn btn-primary">全部功能</li>
                <li class="mt40">
                    <a href="./user_center.php?act=user_info" class="btn btn-default user_center">
                        个人信息修改
                    </a>
                </li>
                <li class="mt40">
                    <a href="./user_center.php?act=user_head" class="btn btn-default" >
                        头像修改
                    </a>
                </li>
                <li class="mt40">
                    <a href="./user_center.php?act=update_pwd" class="btn btn-default" >
                        密码修改
                    </a>
                </li>
                <li class="mt40">
                    <a href="./user_center.php?act=bought" class="btn btn-default" >
                        已买到的宝贝
                    </a>
                </li>
                <li class="mt40">
                    <a href="./user_center.php?act=myorder" class="btn btn-default" >
                        我的订单
                    </a>
                </li>
            </ul>
        </div>
    </div>
    <div class="row mt50 col-md-8">
        <?php require ROOT_PATH.'com/myorder.php'?>
        <?php require ROOT_PATH.'com/bought.php'?>
        <?php require ROOT_PATH.'com/user_info.php'?>
        <?php require ROOT_PATH.'com/pwd.php'?>
        <?php require ROOT_PATH.'com/user_head.php'?>
    </div>
</div>
